<?
/**
 * Copyright 2007 Melange.
 *
 * This file is part of Melange_Framework
 *
 * PHP-HTTP is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * PHP-HTTP is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with PHP-HTTP; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * @package aas
 *
 */

/**
 * Abstract group class
 *
 * <p>Convenience base class for {@link Group} implementations.</p>
 *
 * @category    Melange Framework
 * @package     aas
 * @copyright   Copyright (c) 2007 Jeroen Simons. All rights reserved
 * @author      Jeroen Simons <jeroen@melange.nl>
 * @link        http://www.melange.nl/
 */
abstract class AbstractGroup { //implements Group 


    // ----------------------------------------------------- Instance Variables


    /**
     * The description of this group.
     */
    protected $description = null;


    /**
     * The group name of this group.
     */
    protected $groupname = null;


    // ------------------------------------------------------------- Properties


    /**
     * Return the description of this group.
     */
    public function getDescription() {
        return ($this->description);
    }


    /**
     * Set the description of this group.
     *
     * @param description The new description
     */
    public function setDescription($description) {
        $this->description = $description;
    }


    /**
     * Return the group name of this group, which must be unique
     * within the scope of a {@link UserDatabase}.
     */
    public function getGroupname() {
        return ($this->groupname);
    }


    /**
     * Set the group name of this group, which must be unique
     * within the scope of a {@link UserDatabase}.
     *
     * @param groupname The new group name
     */
    public function setGroupname($groupname) {
        $this->groupname = $groupname;
    }


    /**
     * Return the set of {@link Role}s assigned specifically to this group.
     */
    abstract public function getRoles();


    /**
     * Return the {@link UserDatabase} within which this Group is defined.
     */
    abstract public function getUserDatabase();


    /**
     * Return the set of {@link User}s that are members of this group.
     */
    abstract public function getUsers();


    // --------------------------------------------------------- Public Methods


    /**
     * Add a new {@link Role} to those assigned specifically to this group.
     *
     * @param $role The new $role
     */
    abstract public function addRole(Role $role);


    /**
     * Is this group specifically assigned the specified {@link Role}?
     *
     * @param $role The $role to check
     */
    abstract public function isInRole(Role $role);


    /**
     * Remove a {@link Role} from those assigned to this group.
     *
     * @param $role The old $role
     */
    abstract public function removeRole(Role $role);


    /**
     * Remove all {@link Role}s from those assigned to this group.
     */
    abstract public function removeRoles();


    // ------------------------------------------------------ Principal Methods


    /**
     * Make the principal name the same as the group name.
     */
    public function getName() {
        return ($this->getGroupname());
    }

}
?>